/**
 * @fileoverview This is a file where deprecation checks are disabled.
 * @suppress {undefinedVars}
 */
// the above is for the Google Closure Compiler ant task

function updateRankings(){
//	$("#viewCSS").attr("href", "highScores.css");
    console.log("in updateRankings");
    var table = $('<table>');
    table.append('<tr><th>Mängija</th><th>Võite</th><th>Kaotusi</th><th>Võiduprotsent</th></tr>');


    console.log("starting get request to highscoresservlet");
    console.log("temp 1");
    $.get("getHighScores", function(data) {
        console.log("finished get request to getHighScores HighScoresServlet");
        console.log(data);
        console.log(data[0]);
        console.log(data.length);
        console.log(data[0].name);
        console.log(data[0].winPercentage);

        for (var i=0; i<data.length; i++){
            table.append('<tr><td>'+ String(data[i].name)+'</td><td>'+String(data[i].winPoints)+'</td><td>'+ String(data[i].losePoints)+'</td><td>'+ String(data[i].winPercentage)+'%</td></tr>');
        }
    }, "json");


//    console.log("starting ajax");
//    $.ajax({
//        type: "GET",
//        url: "getHighScores",
//        dataType: "text",
//        success: function(data) {
//            console.log("finished get request to getHighScores HighScoresServlet");
//            console.log(data);
//            console.log(data[0]);
//            console.log(data.length);
//            console.log(data[0].name);
//            console.log(data[0].winPercentage);
//
//            for (var i=0; i<data.length; i++){
//                table.append('<tr><td>'+ String(data[i].name)+'</td><td>'+String(data[i].winPoints)+'</td><td>'+ String(data[i].losePoints)+'</td><td>'+ String(data[i].winPercentage)+'%</td></tr>');
//            }
//        },
//        error: function(jqXHR, textStatus, errorThrown) {
//            console.log("server returned error: " + errorThrown);
//        },
//        complete: function() {
//            console.log("completed ajax get");
//        }
//    });




    $('#scoresTable').replaceWith(table);
    console.log("replaced scores table");
}

function servlettest3(){
	$.get("getHighScores", function(data) {
		console.log(data);
		console.log(data[0]);
		console.log(data.length);
		console.log(data[0].name);
		console.log(data[0].winPercentage);
		
		for (var i=0; i<data.legth; i++){
			table.append('<tr><td>'+ String(data[i].name)+'</td><td>'+String(data[i].winPoints)+'</td><td>'+ String(data[i].losePoints)+'</td><td>'+ String(data[i].winPercentage)+'%</td></tr>');
		}
}, "json");

}


//$("#score").click(function() {
//    $("#viewCSS").attr("href", "highScores.css");
//    updateRankings();
//    console.log("tere");
//});


